package com.itheima.HomeWork_day09;

import java.util.HashSet;
import java.util.Iterator;

public class HashTest {
    public static void main(String[] args) {

        //创建Hash集合
        HashSet<String> hs = new HashSet<>();

        //添加元素
        hs.add("aaa");
        hs.add("bbb");
        hs.add("aaa");
        hs.add("sss");
        hs.add("ooo");

        //遍历集合

        //迭代器进行遍历
        Iterator<String> it = hs.iterator();
        while (it.hasNext()) {
            String s = it.next();
            System.out.println(s);
        }

        //for遍历
        System.out.println("============================");

        for (String h : hs) {
            System.out.println(h);
        }

    }
}
